package com.WJY.dao;

import com.WJY.pojo.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BookDao {

    //查询所有图书
    @Select("select * from book")
    List<Book> queryBookList();

    //根据图书名称模糊查询图书
    @Select("select * from book where bookName like '%${bookName}%'")
    List<Book> queryBookByBookName(@Param("bookName") String bookName);

    //根据id查询图书
    @Select("select * from book where bookId = #{id}")
    Book queryBookById(@Param("id") int id);

    //根据ID删除图书
    @Delete("delete from book where bookId = #{id}")
    int delBookById(@Param("id") int id);

    //新增图书
    @Insert("insert into book (bookName, bookAuthor, bookPublisher) values (#{bookName},#{bookAuthor},#{bookPublisher})")
    int addBook(Book book);

    //修改图书
    @Update("update book set bookName = #{bookName}, bookAuthor = #{bookAuthor}, bookPublisher = #{bookPublisher} where bookId = #{bookId} ")
    int updateBook(Book book);

}
